package com.ruoyi.web.controller.nysjwh;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.nysjwh.domain.TbNysjwhNysjlr;
import com.ruoyi.nysjwh.service.ITbNysjwhNysjlrService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 能源数据录入Controller
 * 
 * @author hc
 * @date 2023-11-11
 */
@RestController
@RequestMapping("/nysjwh/nysjlr")
public class TbNysjwhNysjlrController extends BaseController
{
    @Autowired
    private ITbNysjwhNysjlrService tbNysjwhNysjlrService;

    /**
     * 查询能源数据录入列表
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:nysjlr:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbNysjwhNysjlr tbNysjwhNysjlr)
    {
        startPage();
        List<TbNysjwhNysjlr> list = tbNysjwhNysjlrService.selectTbNysjwhNysjlrList(tbNysjwhNysjlr);
        return getDataTable(list);
    }

    /**
     * 导出能源数据录入列表
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:nysjlr:export')")
    @Log(title = "能源数据录入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbNysjwhNysjlr tbNysjwhNysjlr)
    {
        List<TbNysjwhNysjlr> list = tbNysjwhNysjlrService.selectTbNysjwhNysjlrList(tbNysjwhNysjlr);
        ExcelUtil<TbNysjwhNysjlr> util = new ExcelUtil<TbNysjwhNysjlr>(TbNysjwhNysjlr.class);
        util.exportExcel(response, list, "能源数据录入数据");
    }

    /**
     * 获取能源数据录入详细信息
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:nysjlr:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbNysjwhNysjlrService.selectTbNysjwhNysjlrById(id));
    }

    /**
     * 新增能源数据录入
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:nysjlr:add')")
    @Log(title = "能源数据录入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbNysjwhNysjlr tbNysjwhNysjlr)
    {
        return toAjax(tbNysjwhNysjlrService.insertTbNysjwhNysjlr(tbNysjwhNysjlr));
    }

    /**
     * 修改能源数据录入
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:nysjlr:edit')")
    @Log(title = "能源数据录入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbNysjwhNysjlr tbNysjwhNysjlr)
    {
        return toAjax(tbNysjwhNysjlrService.updateTbNysjwhNysjlr(tbNysjwhNysjlr));
    }

    /**
     * 删除能源数据录入
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:nysjlr:remove')")
    @Log(title = "能源数据录入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbNysjwhNysjlrService.deleteTbNysjwhNysjlrByIds(ids));
    }
}
